package database.mediator;

import java.util.ArrayList;

import distributedRE.model.DataBase;
import distributedRE.model.Document;
import distributedRE.model.Query;
import distributedRE.model.Relation;
import distributedRE.model.Tuple;

public interface MediatorInterface {

	public static final long DOC_NOT_FOUNDED = 0;
	
	void openConnection();

	void closeConnection();

	void writeExperiment(Integer experimentId, long relationId, String dateTime,
			String environment, String qdbs, String search_engine, String stop_policy,
			String adjustment, String ranking_generator);

	void writeSession(int experimentId, int sessionId, long measuredTime);

	void writeSessionResult(int experimentId, int sessionId, long queryId, long databaseId,
			int position, Comparable<?> score);

	void writeQuerySession(long queryId, long databaseId, int experimentId, int sessionId,
			long measuredTime);

	void writeQueryResults(long queryId, long databaseId, int experimentId, int sessionId,
			long documentId, int position, Comparable score);

	void writeIEonDocument(String informationExtractorId, long documentId, boolean useful,
			long measuredTime);

	void writeUsedIE(Integer idExperiment, String informationExtractorId);

	void writeInitialPrecision(long queryId, long databaseId, double initialPrecision);

	void writeTuple(long informationExtractorId, long relationId, long tupleId, String text, long ie_rootId, long r_rootId, long rootId);
	
	void writeTuple(String informationExtractorId, String relationId, String tupleId, String text);

	void writeDocumentTuple(long documentId, String informationExtractorId, long r_id, long tupleId);

	void writeEndDate(Integer experimentId, String dateTime);

	void writeAdaptiveStep(int experimentId, int sessionId, long adjustmentId, long measuredTime);

	ArrayList<String> getProcessedDocuments(String informationExtractorid);

	ArrayList<Tuple> getStoredTuples(String informationExtractorId, Long relationId, Long documentId);

	ArrayList<DataBase> readDatabases(long[] databasesId);

	ArrayList<Query> readQueries(long[] queriesId);

	public void writeAdjustment(int adjustmentId, String description, String frequency);

	public void writeDatabase(int databaseId, String url, int sampleSize, int words_number, int documents_number,
			String cs_path, String index_path, String local_path, long maxretrievable, long concurrentQueries);

	public void writeDocument(long nextId, String absolutePath, long databaseId);

	public void writeExtractsFor(int informationExtractorId, int relationId, String attributes, String inferred_attributes);

	public void writeInformationExtractor(int informationExtractorId, String description);

	public void writeRelation(int relationId, String description);

	void writeQuery(long queryId, String text, String informationExtractionId, String relationId);

	Relation readRelation(long relationId);

	double getInitialPrecision(long queryId, long databaseId);

	Document getDocument(long database_id, String url);

	public long getDocumentId(String url, long databaseId);

	long getNextQueryId();
	
	long getNextDocumentId();

	long getNextTupleId(long informationExtractionId, long relationId);

	boolean hasDocumentBeenProcessed(long documentId, String informationExtractionId);

}
